<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function(){
				$("#btnSearch").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
		        	dateFormat(document.getElementById("startDate"));
		        	dateFormat(document.getElementById("endDate"));
					$("#searchForm").submit();
				});
		        $("[name=btnView]").button({
		            icons: {
		                primary: "ui-icon-search"
		            },
            		text: false
		        });
		        
		        thaiDatepicker("startDate","#","1");
		        thaiDatepicker("endDate","#","1");
			});
			function viewExpense(docNo,budgetYear,provinceId){
				window.location='${pageContext.request.contextPath}/acc6?app=ACC60306&job=view&docNo='+docNo+'&budgetYear='+budgetYear+'&provinceId='+provinceId;
			}
		</script>
	</head>
	<body>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC60306"/>
		<input type="hidden" name="job" id="job" value="${job}"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC60306}</b></th>
			</tr>
			<tr>
				<td width="20%" class="bold">จังหวัด : </td>
				<td>
					<c:if test="${userInfo.areaLevel =='3'}">
						<c:forEach var="data" items="${userInfo.listUserProvice}">
							${data.provinceName}
							<input type="hidden" name="provinceId" id="provinceId" value="${data.provinceId}">
						</c:forEach>
					</c:if>
					<c:if test="${userInfo.areaLevel=='1' || userInfo.areaLevel=='2'}">
						<select name="provinceId" id="provinceId">
							<option value="">----- เลือก -----</option>
							<c:forEach var="data" items="${userInfo.listUserProvice}">
								<c:if test="${data.provinceId == provinceId}" var="provinceSeleted"/>
								<option value="${data.provinceId}" ${provinceSeleted?'selected':''}>${data.provinceName}</option>
							</c:forEach>
						</select>
					</c:if>
				</td>
			</tr>
			<tr>
				<td class="bold">ปีงบประมาณ : </td>
				<td>
					<select name="budgetYear" id="budgetYear">
						<option value="">----- เลือก -----</option>
							<c:if test="${!empty listBudgetYear}">
								<c:forEach var="data" items="${listBudgetYear}" varStatus="x">
									<c:if var="selected" test="${budgetYear == data.BUDGET_YEAR}"/>
									<option value="${data.BUDGET_YEAR}" ${selected ? 'selected' : ''}>${data.BUDGET_YEAR}</option>
								</c:forEach>
							</c:if>
					</select>
				</td>
			</tr>
			<tr>
				<td class="bold">เลขที่เอกสาร : </td>
				<td>
					<input type="text" name="docNo" id="docNo" value="${docNo}"/>
				</td>
			</tr>
			<tr>
				<td class="bold">ชื่อการจ่าย : </td>
				<td>
					<input type="text" name="docNo" id="docNo" value="${docNo}"/>
				</td>
			</tr>
			<tr>
				<td class="bold">วันที่จ่าย : </td>
				<td>
					<input type="text" name="startDate" id="startDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${startDate}"/>&nbsp;&nbsp; ถึง  &nbsp;&nbsp;
					<input type="text" name="endDate" id="endDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${endDate}"/>
				</td>
			</tr>
			<tr>
				<td class="bold">สถานะการจ่าย : </td>
				<td>
					<select name="expenseStatus" id="expenseStatus">
						<option value="">----- เลือก -----</option>
						<c:forEach var="es" items="${statusExpense}">
							<c:if var="statusSelected" test="${expenseStatusSel == es.key}"/>
							<option value="${es.key}"} ${statusSelected?'selected':''}>${es.value}</option>
					    </c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<button type="submit" name="btnSearch" id="btnSearch">ค้นหาข้อมูล</button>
				</td>
			</tr>
		</table>
		<br/>
		<c:if test="${!empty pageBean.pageData}">
			<fieldset>
				<legend>ผลการค้นหาข้อมูล</legend>
					<table width="100%" class="acc67-grid ui-widget ui-widget-content" border="0">
						<tr>
							<th align="center" class="ui-state-default" width="10%" onclick="pageControl('S', 'DOC_NO');"><span id="DOC_NO" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>เลขที่เอกสาร</th>
							<th align="center" class="ui-state-default" onclick="pageControl('S', 'EXPENSE_SUBJECT');"><span id="EXPENSE_SUBJECT" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>ชื่อการจ่าย</th>
							<th align="center" class="ui-state-default" onclick="pageControl('S', 'EXPENSE_DATE');"><span id="EXPENSE_DATE" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>วันที่จ่าย</th>
							<th align="center" class="ui-state-default">จำนวนเงิน</th>
							<th align="center" class="ui-state-default" onclick="pageControl('S', 'EXPENSE_STATUS');"><span id="EXPENSE_STATUS" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>สถานะ</th>
							<th align="center" class="ui-state-default" width="7%">เรียกดู</th>
						</tr>
					<c:forEach var="data" items="${pageBean.pageData}" varStatus="x">
						<tr class="grid-tr-${x.count % 2}">
							<td align="center">${data.docNo}</td>
							<td align="center">${data.expenseSubject}</td>
							<td align="center">${el:dateTh(data.expenseDate)}</td>
							<td align="right"><fmt:formatNumber pattern="#,##0.00" value="${el:getDataUtil('ETA',data.docNo)}" /></td>
							<%-- <td align="right"><fmt:formatNumber pattern="#,##0.00" value="${el:getDataUtil('ETA',data.docNo)}" /></td> --%>
							<td align="center">${el:getMapValue(statusExpense,data.expenseStatus)}</td>
							<td align="center"><button type="button" name="btnView" id="btnView" class="acc67-button"  onclick="viewExpense('${data.docNo}','${data.budgetYear}','${data.provinceId}')"/></td>
						</tr>
					</c:forEach>
					</table>
					<input type="hidden" name="formPage" id="formPage" value="searchForm"/>
					<c:import url="/apps/page.jsp"/>
			</fieldset>
		</c:if>
		</form>
	</body>
</html>